<?
	  	  include("/inc/header.html") {}
    ?>
    <link rel="stylesheet" href="static/echarts-2.2.7/doc/asset/css/font-awesome.min.css" type="text/css"></link>
    <link rel="stylesheet" href="static/echarts-2.2.7/doc/asset/css/bootstrap.css" type="text/css"></link>
    <link rel="stylesheet" href="static/echarts-2.2.7/doc/asset/css/carousel.css" type="text/css"></link>
    <link rel="stylesheet" href="static/echarts-2.2.7/doc/asset/css/echartsHome.css" type="text/css"></link>
    
 	 <script type="text/javascript" src="static/echarts-2.2.7/doc/example/www/js/echarts.js"></script>
    <script type="text/javascript" src="static/echarts-2.2.7/doc/asset/js/codemirror.js"></script>
    <script type="text/javascript" src="static/echarts-2.2.7/doc/asset/js/javascript.js"></script>
    
    <link rel="stylesheet" href="static/echarts-2.2.7/doc/asset/css/codemirror.css" type="text/css"></link>
    <link rel="stylesheet" href="static/echarts-2.2.7/doc/asset/css/monokai.css" type="text/css"></link>
    
    <script type="text/javascript" src="static/echarts-2.2.7/doc/asset/js/jquery.min.js"></script>
    <script type="text/javascript" src="static/echarts-2.2.7/doc/asset/js/echartsHome.js"></script>
    <script type="text/javascript" src="static/echarts-2.2.7/doc/asset/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="static/echarts-2.2.7/doc/asset/js/echartsExample.js"></script>
  
          
               <div class="page-content" style="min-height: auto;padding-bottom: 20px; margin-top: -60px;">
                <div id="main" class="main" style="height: 480px;"></div>
             </div>
            


 <script>
 var classid = window.parent.getclassid();
 var classname = window.parent.getclassname();
    // 路径配置
        require.config({
            paths: {
                echarts: 'http://echarts.baidu.com/build/dist'
            }
        });
        
        // 使用
         require(
            [
                'echarts',
                'echarts/chart/force' // 使用柱状图就加载bar模块，按需加载
            ], 
            function (ec) {
            var datas;
                // 基于准备好的dom，初始化echarts图表
                var myChart = ec.init(document.getElementById('main')); 
                	$.ajax({
					type : "post",
					url : "KnowledgeDataProperty.do",
					data : {
						"lid" : classid,
						"classname" : classname
					},
					dataType : "json",
					async : false,
					success : function(data) {
						datas = data;
						//alert(JSON.stringify(data));
					},
					error : function(data) {
						alert("未找到需要内容，请选择类！");
						save();
					}
				});
        var option = {
    			title : {
      			text: classname,
      	 	/* 	subtext: '数据来自人立方', */
      	  		x:'right',
       	 		y:'bottom'
 	  		 },
    		tooltip : {
        		trigger: 'item',
        		formatter: '{a} : {b}'
    		},
    		toolbox: {
        		show : true,
        			feature : {
            			restore : {show: false},
            				magicType: {show: false, type: ['force', 'chord']},
            					saveAsImage : {show: false}
        			}
    		},
    		legend: {
        		x: 'left',
        		data:['数据属性管理','对象属性管理']
    		},
    		series : [
        		{
            		type:'force',
            		name : "字段名",
            		ribbonType: false,
            		categories : [
                {
                    name: '人物'
                },
                {
                    name: '数据属性管理'
                },
                {
                    name:'对象属性管理'
                }
            ],
            itemStyle: {
                normal: {
                    label: {
                        show: true,
                        textStyle: {
                            color: '#333'
                        }
                    },
                    nodeStyle : {
                        brushType : 'both',
                        borderColor : 'rgba(255,215,0,0.4)',
                        borderWidth : 1
                    },
                    linkStyle: {
                       
                    }
                },
                emphasis: {
                    label: {
                        show: false
                        // textStyle: null      // 默认使用全局文本样式，详见TEXTSTYLE
                    },
                    nodeStyle : {
                        //r: 30
                    },
                    linkStyle : {}
                }
            },
            useWorker: false,
            minRadius : 15,
            maxRadius : 25,
            gravity: 1.1,
            scaling: 1.1,
            roam: 'move',
            nodes:datas,
            links : datas
        }
    ]
};
var ecConfig = require('echarts/config');
function focus(param) {
    var data = param.data;
    var links = option.series[0].links;
    var nodes = option.series[0].nodes;
    if (
        data.source !== undefined
        && data.target !== undefined
    ) { //点击的是边
        var sourceNode = nodes.filter(function (n) {return n.name == data.source})[0];
        var targetNode = nodes.filter(function (n) {return n.name == data.target})[0];
        console.log("选中了边 " + sourceNode.name + ' -> ' + targetNode.name + ' (' + data.weight + ')');
    } else { // 点击的是点
        console.log("选中了" + data.name + '(' + data.value + ')');
    }
}
myChart.on(ecConfig.EVENT.CLICK, focus)

myChart.on(ecConfig.EVENT.FORCE_LAYOUT_END, function () {
    console.log(myChart.chart.force.getPosition());
});
                // 为echarts对象加载数据 
                myChart.setOption(option); 
            }
        );
           
	function  save(){
		var index = parent.layer.getFrameIndex(window.name); 
	    parent.layer.close(index);
     }

</script> 



